package com.wwl.collection;

import java.util.*;

public class CollectionDemo {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add("Tom");
        c.add("Mike");
        c.add("Rose");

        Collection c2 = new ArrayList();
        c2.add("张三");
        c2.add("李四");
        c2.add("王五");
        c.addAll(c2);

        //c.retainAll(c2);
        //System.out.println(c);

        System.out.println(c.contains("Tom"));
        System.out.println(c.containsAll(c2));
        c2.clear();
        System.out.println(c.isEmpty());
        System.out.println(c2.isEmpty());

       /* c.remove("Tom");
        c.removeAll(c2);
        c2.add("胡启明");*/

        System.out.println(c.contains("Tom"));
        System.out.println(c.containsAll(c2));

        System.out.println(c);

        Iterator it = c.iterator();
        while(it.hasNext()){
            Object obj = it.next();
            System.out.println("obj===="+obj);
        }

        Collection set = new HashSet();
        set.add("aaa");
        set.add("bbb");
        set.add("aaa");
        System.out.println(set);



    }
}
